﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BKO.Domain.Model;
using BKO.Domain.Repositories;
using BKO.Domain.Services;
using BKO.DataAccesss;
using BKO.DataAccesss.Repositories;

namespace BKO.Services
{
	public class TLogService : ITLogService
	{
		private readonly IRepository<ITLog> _repository;

		public TLogService(string connectionString)
		{
			_repository = new TLogRepository(BKODataContextSingletone.GetInstance(connectionString));
		}

		public List<ITLog> GetAll()
		{
			return _repository.GetAll().ToList();
		}

		public void Add(string userId, string activity, DateTime time)
		{
			ITLog log = _repository.CreateEmpty();
			log.UserID = userId;
			log.Activity = activity;
			log.Time = time;
			_repository.Add(log);
		}

		public void Clear()
		{
			_repository.Clear();
		}
	}
}
